package  
{
	import bulletbehavior.AdjustSizeBehavior;
	import bulletbehavior.DieBehavior;
	import bulletbehavior.RotateBehavior;
	import bulletbehavior.SplitBehavior;
	import bulletbehavior.WaveBehaviorAngular;
	import turretbehavior.SpeedModulationBehavior;
	import turretbehavior.TypeCyclingTurretBehavior;
	import org.flixel.FlxG;
	/**
	 * ...
	 * @author morgan
	 */
	public class Stage3State extends GameState
	{
		
		public function Stage3State() 
		{
			levelName = "1-3";
			levelIndex = 2;
			img_terrain = img_terrain_1;			
		}
		
		override public function setupBoss():void 
		{
			boss = new Boss(FlxG.width / 2 - 70, 10, 0);
			
			var straight:BulletPattern = new BulletPattern();
			
			var turn:BulletPattern = new BulletPattern();
			turn.addBehavior(new RotateBehavior(0, 90), 0, 1);
			
			var wavey:BulletPattern = new BulletPattern();
			wavey.addBehavior(new WaveBehaviorAngular(2, 100, 0.1));
			
			var explode:BulletPattern = new BulletPattern();
			explode.addBehavior(new SplitBehavior(40, 60, 0, 360, straight, -1));
			explode.addBehavior(new DieBehavior());
			
			var explode_lrl:BulletPattern = new BulletPattern();
			explode_lrl.addBehavior(new AdjustSizeBehavior(2));
			explode_lrl.addBehavior(new SplitBehavior(5, 90, 0, 90, straight, 0), 1.0);
			explode_lrl.addBehavior(new SplitBehavior(5, 90, 90, 180, straight, 1), 1.5);
			explode_lrl.addBehavior(new SplitBehavior(5, 90, 180, 270, straight, 2), 2.0);
			explode_lrl.addBehavior(new SplitBehavior(20, 90, 0, 360, straight, -1), 2.5);
			explode_lrl.addBehavior(new DieBehavior(), 2.5);
			
			var splitwave:BulletPattern = new BulletPattern();
			splitwave.addBehavior(new AdjustSizeBehavior(2.0));
			splitwave.addBehavior(new WaveBehaviorAngular(4, 90, 0.2));
			splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 0), 0.5);
			splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 1), 1.0);
			splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 2), 1.5);
			splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 0), 2.0);
			splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 1), 2.5);
			splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 2), 3.0);
			//splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 0), 3.5);
			//splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 1), 4.0);
			//splitwave.addBehavior(new SplitBehavior(8, 80, 0, 360 * 7 / 8, straight, 2), 4.5);
			
			var p1f:BossPattern = new BossPattern();
			var t1t:Turret = new Turret(0, 0, wavey, 0, 90, 50, 0.1);
			t1t.addBehavior(new SpeedModulationBehavior(4, 0.5));
			t1t.addBehavior(new TypeCyclingTurretBehavior(0.8, [0, 1, 0, 1, 0, 2, 0, 2, 1, 2, 1, 2]));
			p1f.addTurretTime(0, Infinity, t1t);
			var t2t:Turret = new Turret(0, 0, explode, 0, 90, 50, 4);
			t2t.addBehavior(new TypeCyclingTurretBehavior(4, [0, 1, 2]));
			p1f.addTurretTime(8, Infinity, t2t);
			
			
			var p2f:BossPattern = new BossPattern();
			var t3t:Turret = new Turret(0, 0, explode_lrl, 0, 90, 40, 3.0);
			t3t.addBehavior(new TypeCyclingTurretBehavior(2, [2, 1, 0]));
			p2f.addTurretTime(0, Infinity, t3t);
			
			var p3f:BossPattern = new BossPattern();
			var t4t:Turret = new Turret(0, 0, splitwave, 0, 90, 40, 6);
			t4t.addBehavior(new TypeCyclingTurretBehavior(5, [2, 1, 0]));
			p3f.addTurretTime(0, Infinity, t4t);
			
			boss.addState(new BossState(1300, p1f));
			boss.addState(new BossState(1000, p2f));
			boss.addState(new BossState(400, p3f));			
		}
		
	}

}